home *** CD-ROM | disk | FTP | other *** search
/ Zoom 2 / Zoom - Release 2 (1996)(Active Software)[!].iso / utilities / blankers / blitzblank_260 / developer / modulesources / bb.amigasign.c next >
C/C++ Source or Header  |  1995-02-28  |  7KB  |  234 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <dos/dos.h>
  5. #include <exec/memory.h>
  6. #include <intuition/intuitionbase.h>
  7. #include <intuition/screens.h>
  8. #include <intuition/intuition.h>
  9. #include <proto/exec.h>
  10. #include <proto/intuition.h>
  11. #include <proto/graphics.h>
  12. #include <pragmas/blitzblank_pragmas.h>
  13.  
  14. #include <BlitzBlank.h>
  15. #include <iff.h>
  16.  
  17. struct Library *BlitzBlankBase,*IFFBase;
  18. static const char version[]="$VER: BB.AmigaSign 2.50 (30.01.94)";
  19.  
  20. char *text[]={"\33c\33uAmigaSign\33n\n\nModule for BlitzBlank\n\nCopyright 1995\nby\nThomas Börkel\n\nGraphics by Alexander Wiggert",
  21.               "_Movement:",
  22.               "_Rotspeed:",
  23.               "Sp_eed:",
  24.               "_Buffering:",
  25.               "horizontal",
  26.               "vertical",
  27.               "diagonal" };
  28.  
  29. char *cycleentries[4]={NULL,NULL,NULL,NULL};
  30.  
  31. struct BB_Object object[]={ {&object[1],BB_VGroup,0,0,0,NULL,NULL},
  32.                             {&object[2],BB_Cycle,0,0,2,(char *)cycleentries,NULL},
  33.                             {&object[3],BB_Slider,-5,5,0,NULL,NULL},
  34.                             {&object[4],BB_Slider,1,10,10,NULL,NULL},
  35.                             {&object[5],BB_Check,0,0,0,NULL,NULL},
  36.                             {NULL      ,BB_VGroup_End,0,0,0,NULL,NULL} };
  37.  
  38.  
  39.  
  40. struct BB_Message message;
  41. struct BB_Screeninfo *screeninfo;
  42. int depth=4;
  43.  
  44. void blank (void)
  45. {
  46.   char file[256],actual,stop=FALSE;
  47.   int count,dx=0,dy=0,sizex=110,sizey=80,xpos,ypos,buf=0,db,rotdelay,rotcount=0,piccount=1,i,movedelay,movecount=0;
  48.   UWORD colortable[256];
  49.   ULONG dbufhandle;
  50.   IFFL_HANDLE iff,form,loopform;
  51.   struct IFFL_BMHD *bmhd;
  52.   struct ViewPort *vp;
  53.   struct BitMap *bm[4]={NULL};
  54.  
  55.   vp=&screeninfo->bbscreen->ViewPort;
  56.   bm[0]=screeninfo->bbscreen->RastPort.BitMap;
  57.  
  58.   if (object[1].set==0 || object[1].set==2)
  59.     dx=1;
  60.   if (object[1].set==1 || object[1].set==2)
  61.     dy=1;
  62.  
  63.   rotdelay=-object[2].set;
  64.   if (rotdelay<0)
  65.   {
  66.     piccount=-rotdelay+1;
  67.     rotdelay=0;
  68.   }
  69.  
  70.   movedelay=10-object[3].set;
  71.  
  72.   db=object[4].set;
  73.  
  74.   xpos=screeninfo->width/2-sizex/2;
  75.   ypos=screeninfo->height/2-sizey/2;
  76.  
  77.   if (db)
  78.   {
  79.     bm[1]=BBL_AllocDBufBitMap (screeninfo->bbscreen);
  80.     dbufhandle=BBL_InitDBuf (screeninfo->bbscreen,bm[1]);
  81.   }
  82.  
  83.   if (!db || (bm[1] && dbufhandle))
  84.   {
  85.  
  86.     strcpy (file,message.path);
  87.     strcat (file,"BB.AmigaSign.data");
  88.  
  89.     if ((iff=IFFL_OpenIFF (file,IFFL_MODE_READ)))
  90.     {
  91.       form=(IFFL_HANDLE)((UBYTE *)iff+12);
  92.       if ((bmhd=IFFL_GetBMHD (form)))
  93.       {
  94.         count=IFFL_GetColorTab (form,(WORD *) colortable);
  95.         LoadRGB4 (vp,colortable,count);
  96.         if ((bm[2]=BBL_AllocBitMap (sizex+10,sizey+10,depth,BMF_CLEAR)))
  97.         {
  98.           if ((bm[3]=BBL_AllocBitMap (sizex+10,sizey+10,depth,BMF_CLEAR)))
  99.           {
  100.             if ((IFFL_DecodePic(form,bm[2])))
  101.             {
  102.               if (!CheckSignal (SIGBREAKF_CTRL_C))
  103.               {
  104.                 ScreenToFront (screeninfo->bbscreen);
  105.                 BBL_ModuleRunning ();
  106.                 IFFL_DecodePic (form,bm[3]);
  107.                 form=IFFL_FindChunk (form,0L);
  108.                 if ((IFFL_ModifyFrame (form,bm[2])))
  109.                 {
  110.                   loopform=IFFL_FindChunk (form,0L);
  111.                   actual=3;
  112.                   form=loopform;
  113.                   do
  114.                   {
  115.                     if (rotcount==0)
  116.                     {
  117.                       for (i=1;i<=piccount;i++)
  118.                       {
  119.                         if ((IFFL_ModifyFrame (form,bm[actual])))
  120.                         {
  121.                           if (actual==3)
  122.                             actual=2;
  123.                           else
  124.                             actual=3;
  125.                         }
  126.                         else
  127.                           stop=TRUE;
  128.                         form=IFFL_FindChunk (form,0L);
  129.                         if (*(ULONG *)form!=ID_FORM)
  130.                           form=loopform;
  131.                       }
  132.                       rotcount=rotdelay;
  133.                     }
  134.                     else
  135.                       rotcount--;
  136.                     if (!db)
  137.                       WaitTOF ();
  138.                     BltBitMap (bm[actual],0,0,bm[buf],xpos,ypos,sizex,sizey,0xc0,0xff,NULL);
  139.  
  140.                     if (db)
  141.                     {
  142.                       WaitBlit ();
  143.                       BBL_ShowBitMap (screeninfo->bbscreen,bm[buf],dbufhandle);
  144. //                      WaitTOF ();
  145.                       buf=1-buf;
  146.                     }
  147.  
  148.                     if (movecount==0)
  149.                     {
  150.                       xpos+=dx;
  151.                       ypos+=dy;
  152.                       movecount=movedelay;
  153.                     }
  154.                     else
  155.                       movecount--;
  156.                     if (xpos+sizex>screeninfo->width || xpos<0)
  157.                     {
  158.                       dx=-dx;
  159.                       xpos+=dx+dx;
  160.                     }
  161.                     if (ypos+sizey>screeninfo->height || ypos<0)
  162.                     {
  163.                       dy=-dy;
  164.                       ypos+=dy+dy;
  165.                     }
  166.                   } while (!CheckSignal (SIGBREAKF_CTRL_C) && !stop);
  167.                   ScreenToBack (screeninfo->bbscreen);
  168.                 }
  169.               }
  170.             }
  171.             BBL_FreeBitMap (bm[3]);
  172.           }
  173.           BBL_FreeBitMap (bm[2]);
  174.         }
  175.       }
  176.       IFFL_CloseIFF (iff);
  177.     }
  178.   }
  179.   if (db)
  180.   {
  181.     BBL_ShowBitMap (screeninfo->bbscreen,bm[0],dbufhandle);
  182. //    WaitTOF ();
  183.     BBL_EndDBuf (dbufhandle);
  184.     BBL_FreeBitMap (bm[1]);
  185.   }
  186.   return;
  187. }
  188.  
  189.  
  190. void main (int argc,char **argv)
  191. {
  192.   int i;
  193.  
  194.   if ((BlitzBlankBase=OpenLibrary ("blitzblank.library",BLITZBLANKLIB_VER)))
  195.   {
  196.     if ((IFFBase=OpenLibrary ("iff.library",23)))
  197.     {
  198.       message.flags=BBF_Screenmode;
  199.       message.first=&object[0];
  200.  
  201.       if (strcmp (argv[1],"BLANK")==0)
  202.       {
  203.         StrToLong (argv[3],(long *) &screeninfo);
  204.         screeninfo->depth=depth;
  205.         BBL_SendMessage (&message,argv[2]);
  206.         if (screeninfo->bbscreen)
  207.           blank ();
  208.         BBL_BlankDone ();
  209.       }
  210.       else
  211.       {
  212.         message.infotext=BBL_GetString (320,text[0]);
  213.         for (i=1;i<=4;i++)
  214.            object[i].label=BBL_GetString (320+i,text[i]);
  215.         cycleentries[0]=BBL_GetString (325,text[5]);
  216.         cycleentries[1]=BBL_GetString (326,text[6]);
  217.         cycleentries[2]=BBL_GetString (327,text[7]);
  218.         if (strcmp (argv[1],"CONFIG")==0)
  219.         {
  220.           BBL_SendMessage (&message,argv[2]);
  221.         }
  222.         else
  223.         {
  224.           message.first=NULL;
  225.           BBL_SendMessage (&message,argv[2]);
  226.         }
  227.       }
  228.       CloseLibrary (IFFBase);
  229.     }
  230.     CloseLibrary (BlitzBlankBase);
  231.   }
  232.   exit (0);
  233. }
  234.